package com.bootcamp.servlet.mvc.utils;

/**
 * @program: wrok-1101
 * @description:
 * @author: Keyu Li
 * @create: 2021-11-07 21:20
 **/

public class StringUtils {
    public static boolean isEmpty(String s) {
        if (s == null || "".equals(s.trim())) {
            return true;
        }
        return false;
    }

    public static boolean isEnglishAndNumber(String s) {
        if (isEmpty(s)) return false;
        char[] chars = s.toCharArray();
        for (char c : chars) {
            if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
                continue;
            }
            return false;
        }
        return true;
    }

    public static boolean isNumber(String s) {
        if (isEmpty(s)) return false;
        char[] chars = s.toCharArray();
        for (char c : chars) {
            if (c >= '0' && c <= '9') {
                continue;
            }
            return false;
        }
        return true;
    }
}
